<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="utf-8"/>
    <title>管理系统</title>

    <meta name="description" content=""/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"/>
    <link rel="stylesheet" th:href="@{/font-awesome/4.5.0/css/font-awesome.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/fonts.googleapis.com.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace.min.css}" class="ace-main-stylesheet" id="main-ace-style"/>
    <link rel="stylesheet" th:href="@{/css/ace-part2.min.css}" class="ace-main-stylesheet"/>
    <link rel="stylesheet" th:href="@{/css/ace-skins.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-rtl.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/ace-ie.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/dataTables.bootstrap4.min.css}"/>
    <script th:src="@{/js/ace-extra.min.js}"></script>
    <script th:src="@{/js/html5shiv.min.js}"></script>
    <script th:src="@{/js/respond.min.js}"></script>
</head>

<body class="no-skin">
<!--头导航栏-->
<div th:replace="common/bar::#navbar"></div>
<div class="main-container ace-save-state" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.loadState('main-container')
        } catch (e) {
        }
    </script>
    <!-- 侧导航栏 -->
    <div th:replace="common/bar::#sidebar"></div>

    <div class="main-content">
        <div class="main-content-inner">
            <div class="breadcrumbs ace-save-state" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li>
                        <i class="ace-icon fa fa-home home-icon"></i>
                        <a href="#">sys</a>
                    </li>
                    <li class="active">index</li>
                </ul><!-- /.breadcrumb -->
            </div>
            <div class="modal fade" id="select_auditor_modal">
                <div class="modal-dialog modal-sm">
                    <div class="modal-content">
                        <!-- 模态框头部 -->
                        <div class="modal-header">
                            <h4 class="modal-title">选择审核签发员</h4>
                            <button type="button" class="close" data-dismiss="modal">&times;</button>
                        </div>
                        <!-- 模态框主体 -->
                        <div class="modal-body row">
                            <div class="col-sm-6">
                                <p>审核员</p>
                                <select class="chosen-select form-control" id="selectShy">
                                    <option th:each="shy:${shys}"
                                            th:value="${shy?.userId}">
                                        [[${shy?.holder}]]
                                    </option>
                                </select>
                            </div>
                            <div class="col-sm-6">
                                <p>签发员</p>
                                <select class="chosen-select form-control" id="selectQfy">
                                    <option th:each="qfy:${qfys}"
                                            th:value="${qfy?.userId}">
                                        [[${qfy?.holder}]]
                                    </option>
                                </select>
                            </div>
                        </div>
                        <!-- 模态框底部 -->
                        <div class="modal-footer">
                            <button type="button" class="btn btn-success" id="submitSelectModal" data-dismiss="modal">
                                提交
                            </button>
                            <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                        </div>
                    </div>
                </div>
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-sm-3 widget-box">
                        <div class="widget-header">
                            <h4 class="widget-title" style="color: black">选择分类</h4>
                        </div>
                        <select class="form-control" id="select_client" multiple="multiple"
                                style="height:0px;padding-bottom: 100%;">
                            <option th:each="client:${clients}"
                                    th:value="${client?.clientId}">
                                [[${client?.clientName}]]
                            </option>
                        </select>
                    </div>
                    <div class="table-responsive col-sm-9">
                        <table class="table table-bordered table-hover text-nowrap" id="dateTable"
                               cellspacing="0">
                            <thead>
                            <tr>
                                <th>原始报告id</th>
                                <th>报告编号</th>
                                <th>检测日期</th>
                                <th>委托单位</th>
                                <th>联系人</th>
                                <th>委托单位地址</th>
                                <th>状态</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->

    <div class="footer">
        <div class="footer-inner">
            <div class="footer-content">
                <span class="bigger-120">
                    <span class="blue bolder">Ace</span>
                    管理系统 &copy; 2020
                </span>
            </div>
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->
<script th:src="@{/js/jquery-2.1.4.min.js}"></script>
<script th:src="@{/js/jquery-1.11.3.min.js}"></script>
<script th:src="@{/js/bootstrap.min.js}"></script>
<script th:src="@{/js/ace-elements.min.js}"></script>
<script th:src="@{/js/ace.min.js}"></script>
<script th:src="@{/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/js/dataTables.bootstrap4.min.js}"></script>
<script th:src="@{/custom/common.js}"></script>
<script>
    var columns = [
        {"data": "vorId", visible: false},
        {"data": "bgbh"},
        {"data": "jcrq"},
        {"data": "wtDw"},
        {"data": "wtLxr"},
        {"data": "wtDwdz"},
        {
            "data": "vorStatus",
            render: function (data, type, full) {
                return getStatusName(data,full.vorId);
            }
        },
        {
            render: function (data, type, full) {
                return "<button onclick='vor_view(" + full.vorId + ");'  class='btn btn-info btn-sm'> 查看</button>" +
                    "<button onclick='vor_remove(" + full.vorId + "," + full.vorStatus + ");'  class='btn btn-danger btn-sm'> 删除</button>"+
                    "<button onclick='report_submit(" + full.vorId + ");'  class='btn btn-success btn-sm'> 提交</button>";
            },
        },
    ];
    //加载页面时 , 初始化表格
    $(function () {
        load_table("/vor/getList?status=0",columns);
    });

    $("#select_client").change(function () {
        load_table("/vor/getList?cid=" + $(this).val()+"&status=0",columns);
    });
    //原始记录删除
    function vor_remove(vid, status) {
        var con = confirm("确定删除吗?");
        if (con) {
            $.ajax({
                url: "/vor/remove?vid=" + vid,
                type: "post",
                contentType: "application/json;charset=utf-8",
                success: function (result) {
                    alert(result.message);
                    $("#vor_table").DataTable().ajax.reload();
                }
            });
        }
    }
    function report_submit(vid) {
        $("#select_auditor_modal").modal("show");
        var data = data_load();
        $("#submitSelectModal").click(function () {
            var shyId = $("#selectShy").val();
            var qfyId = $("#selectQfy").val();
            $.ajax({
                url: "/vor/submit",
                type: "post",
                contentType: "application/json;charset=utf-8",
                data: data,
                success: function (result) {
                    alert(result.message);
                    window.location.href = "/vor/submit-view?vid=" + result.data;
                }
            });
        });
    }
</script>
</body>
</html>
